<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/font-awesome.css" />
	</head>
	<body>
		<section class="aui-grid">
			<div class="aui-row" id="list"></div>
		</section>
		<footer class="aui-bar aui-bar-tab" id="footer">
			<div class="aui-bar-tab-item" tapmode id="camera">
				<i class="fa fa-camera"></i>
				<div class="aui-bar-tab-label">
					拍照
				</div>
			</div>
		</footer>
	</body>
	<script id="listTemplate" type="text/x-dot-template">
		{{for(var i=0;i<it.persons.length;i++){}}
		<div class="aui-col-xs-6">
		<div class="aui-card-list-content aui-content-padded"><img src="{{=it.base}}upload/face/idcard/{{=it.persons[i].person.avatar}}">
		</div>
		<div class="aui-grid-label">
		{{=it.persons[i].person.name}}
		</div>
		<div class="aui-grid-label">
		{{=it.persons[i].house.building}}楼{{=it.persons[i].house.floor}}层{{=it.persons[i].house.room}}房间{{=it.persons[i].house.bed}}床
		</div>
		<div class="aui-grid-label">
		相似度：{{=it.persons[i].confidence}}
		</div>
		</div>
		{{}}}
	</script>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/util.js" ></script>
	<script type="text/javascript" src="../../script/doT.js" ></script>
	<script type="text/javascript">
		apiready = function() {
			api.parseTapmode();
			// 拍照
			$api.addEvt($api.byId('camera'), 'click', function() {
				api.getPicture({
					sourceType : 'camera',
					encodingType : 'jpg',
					mediaValue : 'pic',
					destinationType : 'url',
					targetWidth : 480,
					targetHeight : 800,
					quality : 100
				}, function(ret, err) {
					//console.log(JSON.stringify(ret));
					if (ret && ret.data != "") {
						api.showProgress({
						});
						api.ajax({
							url : base + 'api/face/doSearch',
							method : 'post',
							data : {
								files : {
									image : ret.data
								}
							}
						}, function(ret, err) {
							if (ret && ret.code != "-1") {
								ret.base = base;
								console.log(JSON.stringify(ret));
								var template = $api.byId('listTemplate');
								var list_content = $api.byId('list');
								var pagefn = doT.template(template.text);
								$api.html(list_content, pagefn(ret));
							} else {
								doLogin();
							}
							api.hideProgress();
						});
					} else {
						tips('请拍照后再进行识别');
					}
				});
			});
		};
	</script>
</html>